package com.koro.controller;

import com.koro.dto.FindUsersDTO;
import com.koro.service.UsersService;
import com.koro.vo.FindUsersVO;
import com.koro.vo.ResponseObject;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags = "用户管理")
@RequestMapping("/user")
@RestController
public class UsersController {

    @Autowired
    private UsersService usersService;

    @ApiOperation(value = "用户查询",notes = "用户查询")
    @PostMapping("/findById")
    public ResponseObject<FindUsersVO> findById(@RequestBody FindUsersDTO dto) {
        return ResponseObject.ok(usersService.findById(dto));
    }

    @ApiOperation(value = "查询所有用户",notes = "查询所有用户")
    @GetMapping("/findAll")
    public ResponseObject<List<FindUsersVO>> findAll(@RequestParam("type") Integer type) {
        return ResponseObject.ok(usersService.findAll(type));
    }
}
